<?php

/**
 * Adds device table
 *
 */
class Db_015_bbce_add_device_table extends Ot_Migrate_Migration_Abstract
{
    public function up($dba)
    {
        $query = "CREATE TABLE  `" . $this->tablePrefix . "tbl_device` (
            `deviceId` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
            `accountId` INT UNSIGNED NOT NULL ,
            `ip` VARCHAR( 15 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
            `name` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
            `description` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
            `lng` FLOAT( 10, 6 ) NOT NULL ,
            `lat` FLOAT( 10, 6 ) NOT NULL ,
            `type` VARCHAR( 64 ) NOT NULL ,
            `enabled` TINYINT NOT NULL DEFAULT  '1',
            UNIQUE (
            `ip`
            )
            ) ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_general_ci;
        ";
        
        $dba->query($query);        
    }
    
    public function down($dba)
    {       
        $query = "";
        $dba->query($query);
    }
}